import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;
class Imp implements Comparator<Integer>{


    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }

public class test2 {

    }
    public static void main(String[] args) {
        Imp imp = new Imp();

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(imp);
        //默认是小根堆；offer是向上转；
        //PriorityBlockingQueue线程安全，上者线程不安全
        //插入堆的元素或者对象必须能比较
        priorityQueue.offer(2);
        priorityQueue.offer(9);
        while(!priorityQueue.isEmpty()) {
            System.out.println(priorityQueue.poll());
        }


    }
}
